<script type="text/javascript">    
    $(document).ready(function(){
        $('#txtFind').focus();
        $("#txtFind").keypress(function(event) {
            if(event.keyCode == 13) { //Enter keycode
                $('#btnFind').focus();
            }
        });
    });
</script>
<div class="form">
    <?php echo Html::beginForm('index'); ?>
    <table>
        <tr>
            <td>
                <table style="width: 100%">
                    <tr>
                        <td style="width: 250px;font-weight: bold; vertical-align: top" class="search-form">                
                            <?php
                            $name = isset($_POST["txtFind"]) ? $_POST["txtFind"] : "";
                            echo Html::textField("txtFind", $name, array(
                                'style' => 'width:130px; margin-right:2px',
                                'placeholder' => t('LBL_USER_USERNAME', 'dashboard'),
                            ));
                            ?>                            
                            <input id="btnFind" class="button" type="submit" value="Search" name="">
                        </td>            
                    </tr>
                    <tr>
                        <td style="width: 200px; vertical-align: top">
                            <div id="div-users">
                                <?php
                                if ($data['usersByName'] != NULL)
                                {
                                    echo Html::dropDownList('users', null, Html::listData($data['usersByName'], 'id', 'username'), array(
                                        'size' => 20,
                                        'class' => 'dropdown',
                                        'style' => 'width:200px',
                                        'onchange' => '$("#div-roles").html("<div class=\"ajax-loading\"></div>");',
                                        'ajax' => array(
                                            'type' => 'POST',
                                            'url' => array('getRoles'),
                                            'update' => '#div-roles',
                                        ),
                                            )
                                    );
                                }
                                else
                                {
                                    echo '<span style="font-style: italic">No results found.</span>';
                                }
                                ?>                               
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                <div id="div-roles">
                    <?php
                    if (($data['userAssignedRoles'] != NULL) || ($data['userNotAssignedRoles'] != NULL))
                    {
                        $this->renderPartial(
                                '_userAjax', array('model' => $model, 'data' => $data)
                        );
                    }
                    ?>
                </div>
            </td>
        </tr>
    </table>
    <?php echo Html::endForm(); ?>
</div>